<extend name="Public/base" />
<block name="content">
<div id="content" style="min-width:800px;">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{:U('Index/index')}" title="首页" class="tip-bottom"><i
				class="icon-home"></i> 首页</a> <a href="#" class="current">{$meta_title}</a>
		</div>
	</div>
	<div class="container-fluid search-form">
			<form class="m-filter" autocomplete="off">
				<div class="clearfix">
					<a class="pull-left btn btn-success btn-filter-show" id="j-filter-show"><span class="icon-chevron-down"></span></a>
				</div>
				
				<div class="filter-box" id="j-filter-box">
					<!-- 基础信息 -->
					<div class="filter-base filter-group">
						<a class="title"><span class="icon-list"></span> 基础信息</a>
						<span class="control-group">
							<select class="form-control" style="width: 150px;" name="activity_id" id="activity_id" onchange="change_merchant(activity_id, '{:U('Shop/getActivityMerchant')}')">
								<option value=0>选择活动</option>
								<volist name="activity_list" id="vo">
									<option value='{$vo.activity_id}'>{$vo.activity_name|strip_tags}</option>
								</volist>
								{$Think.config.ACTIVITY_TTTM}
							</select>
						</span>
						<span class="control-group">
							<select class="form-control" style="width: 180px;" name="merchant_id" id="merchant_id" onchange="change_shop(activity_id,merchant_id, '{:U('Shop/getMerchantShop')}')">
								<option value=0>选择商户</option>
								<volist name="merchant_list" id="vo">
									<option value='{$vo.merchant_id}'>{$vo.merchant_name|strip_tags}</option>
								</volist>
							</select>
						</span>
						<span class="control-group">
							<select class="form-control" style="width: 150px;" name="shop_id" id="shop_id">
								<option value=0>选择店铺</option>
								<volist name="shop_list" id="vo">
									<option value='{$vo.shop_id}'>{$vo.shop_name|strip_tags}</option>
								</volist>
							</select>
						</span>
						<span class="control-group">
						<select class="form-control" style="width: 150px;" name="create_user_id" id="create_user_id">
							<option value=0>操作人</option>
							<volist name="user_list" id="vo">
								<option value='{$vo.uid}'>{$vo.login_name|strip_tags}</option>
							</volist>
						</select>
						<button type="button" url="{:U('Order/export')}" class="export btn btn-info btn-small" style="height:28px;">导出</button>
					</span>
					</div>
					<!-- /基础信息 -->
					
					<div class="clearfix">
						<!-- 支付方式 -->
						<div class="filter-pay filter-group form-inline pull-left">
						<a class="title"><span class="icon-briefcase"></span> 支付方式</a>
							<label class="radio-group">
					    		<input type="radio" name="pay_type" value="0" checked>全部
					  		</label>
							<volist name="Think.config.ORDER_PAY_TYPE" id="vo_status">
								<if condition="$key neq 0">
									<label class="radio-group">
							    		<input type="radio" name="pay_type" value="{$key}">{$vo_status}
							  		</label>
							  	</if>
							</volist>
						</div>
						<!-- /支付方式 -->
				
						<!-- 流水类型 -->
						<div class="filter-turnover filter-group form-inline pull-left">
						<a class="title"><span class="icon-glass"></span> 流水类型</a>
							<label class="radio-group">
					    		<input type="radio" name="type" value="0" checked>收款（总）
					  		</label>
							<label class="radio-group">
					    		<input type="radio" name="type" value="1">收款（净）
					  		</label>
					  		<label class="radio-group">
					    		<input type="radio" name="type" value="2">退款
					  		</label>
						</div>
						<!-- /流水类型 -->		
					</div>
				
					<!-- 手机&订单号 -->
					<div class="filter-input filter-group clearfix">
						<a class="title"><span class="icon-globe"></span> 手机号&订单号</a>
					  	<div class="control-group pull-left">
					    	<div class="controls">
								<input type="text" name="phone_number" value="{:strip_tags(I('phone_number'))}" placeholder="手机号" class="search-input" maxlength="11" onkeyup="value=value.replace(/[a-zA-z]+$/,'')">
					    	</div>
					  	</div>
					  	<div class="control-group pull-left" style="margin-left:15px;">
					    	<div class="controls">
								<input type="text" name="paper_order" value="{:strip_tags(I('paper_order'))}" placeholder="纸质订单号" class="search-input" maxlength="13" onkeyup="value=value.replace(/[a-zA-z]+$/,'')"> 
					    	</div>
					  	</div>
					  	<div class="control-group pull-left" style="margin-left:15px;">
					    	<div class="controls">
								<input type="text" name="order_id" value="{:strip_tags(I('order_id'))}" placeholder="订单号" class="search-input" maxlength="13" onkeyup="value=value.replace(/[a-zA-z]+$/,'')"> 
					    	</div>
					  	</div>
					  	<div class="control-group pull-left" style="margin-left:15px;">
					    	<div class="controls">
								<input type="text" name="amount" value="{:strip_tags(I('amount'))}" placeholder="流水金额" class="search-input" maxlength="13" > 
					    	</div>
					  	</div>
					</div>
					<!-- /手机&订单号 -->
				
					<!-- 支付日期 -->
					<div class="filter-date filter-group clearfix">
						<a class="title"><span class="icon-calendar"></span> 支付日期</a>
					  	<div class="control-group pull-left">
					    	<div class="controls">
					      		<input type="text" id="start_time" name="start_time" class="datepicker" value="{:strip_tags(I('start_time'))}" readonly="readonly" placeholder="开始时间" style="width:120px; text-align:center;" >
					    	</div>
					  	</div>
					  	<div class="control-group pull-left" style="margin-left:15px;">
					    	<div class="controls">
					      		<input type="text" id="end_time" name="end_time" class="datepicker" value="{:strip_tags(I('end_time'))}" readonly="readonly" placeholder="结束时间" style="width:120px; text-align:center;" >
					    	</div>
					  	</div>　<button type="button" id="c_time" class="btn btn-warning">清除</button>
					</div>
					<!-- /支付日期 -->
				
					<div class="clearfix btn-group">
						<a class="btn btn-success btn pull-left" id="j-filter-hide" style="margin-left:15px;"><span class="icon-chevron-up"></span></a>
						<button type="button" id="search_button" url="{:U('Order/payment')}" class="btn btn-primary btn pull-left"><span class="icon-search"></span></button>
					</div>	
				</div>		
			</form>
		</div>
		
		<div class="container-fluid">
			<div class="row-fluid">
				<div class="span12">
					<div class="widget-box">
						<div class="widget-content">
							<notempty name="_list">
								<table class="table table-bordered table-striped">
									<thead>
										<tr>
											<th nowrap="nowrap">序号</th>
											<th nowrap="nowrap">订单</th>
											<th nowrap="nowrap">纸质订单</th>
											<th nowrap="nowrap">店铺</th>
											<th nowrap="nowrap">品类</th>
											<th>金额</th>
											<th nowrap="nowrap">支付方式</th>
											<th nowrap="nowrap">商户单号</th>
											<th>下单时间</th>
											<th nowrap="nowrap">申请核销时间</th>
											<th>状态</th>
											<th>补打</th>
										</tr>
									</thead>
									<tbody>
										<volist name="_list" id="vo">
											<tr>
												<td class="taskStatus" style="height:23px;">{$i}</td>
												<td nowrap="nowrap" class="taskStatus"><a style="color:#49afcd;" href="{:U('orderInfo?order_id='.$vo['order_id'])}">{$vo.order_id}</a></td>
												<td nowrap="nowrap" class="taskStatus"><a style="color:#49afcd;" href="{:U('orderInfo?order_id='.$vo['order_id'])}">{$vo.paper_order}</a></td>
												<td class="taskStatus" title="{$vo.shop_name|htmlspecialchars}">{$vo.shop_name|htmlspecialchars|msubstr=###,0,20}</td>
												<td class="taskStatus" >{$vo.conf_category_id|getConfCategoryName}</td>
												<td class="taskStatus">{$vo.amount}</td>
												<td nowrap="nowrap" class="taskStatus">{$vo.pay_type|get_pay_title}</td>
												<td class="taskStatus">{$vo.server_order_id|default='-'|htmlspecialchars}</td>
												<td nowrap="nowrap" class="taskStatus">{$vo.create_time|time_format}</td>
												<td nowrap="nowrap" class="taskStatus"><font color="red">{$vo.apply_time|time_format}</font></td>
												<td nowrap="nowrap" class="taskStatus"><if condition="$type gt 0"><if condition="$type eq 1">收款</if><if condition="$type eq 2">退款</if><else />{$vo.type|get_payment_type_title}</if></td>
												<td nowrap="nowrap" class="taskStatus"><if condition="($vo.paper_order gt 0) and ($vo.pay_type neq 9)"><button class="btn btn-mini btn-warning" onclick="pay_print('{$vo.payment_id}')">打印</button></if></td>
											</tr>
										</volist>
									</tbody>
								</table>
									<div class="control-group" style="text-align:right;">
										<h4>共：<font color="#f60">{$_total|default='0'}</font> 笔　总金额：<font color="#f60">{$amount_sum|formatMoney}</font></h4>
									</div>
									<div class="dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_full_numbers" id="DataTables_Table_0_paginate">
										{$_page}
									</div>
							<else/>
								<center>请根据搜索条件进行查询</center>
							</notempty>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(function (){
	//日期控件
	$(".datepicker").datetimepicker({
		format: 'yyyy-mm-dd hh:ii', 
	    autoclose: true,
	    todayBtn: true
	});
	//条件框
	$("#j-filter-hide").click(function(){
		$("#j-filter-box").fadeOut(300);
		$("#j-filter-show").fadeIn(300);
	});
	$("#j-filter-show").click(function(){
		$("#j-filter-box").fadeIn(300);
		$(this).fadeOut(300);
	});
	//导出
	$(".export").click(function(){
		if(!confirm('是否要导出数据？')){
			return false;
		}
		$('.export').attr('disabled', true);
		var url = $(this).attr('url');
		$.post(url, $('form').serialize(), call_back, "json");
		return false;
		function call_back(data){
			$('.export').removeAttr('disabled');
			if(data.status == 1){
				window.location.href = data.info;
			}else{
				tke_alert(data.info, 'alert-error', 5000);
			}
		}
	});
	
	//clear
	$('#c_time').click(function(){
		$('#start_time,#end_time').val('');
	});
	
	set_value("activity_id",'{:I('activity_id')}')
	set_value("merchant_id",'{:I('merchant_id')}')
	set_value("shop_id",'{:I('shop_id')}')
	set_value("pay_type",'{:I('pay_type')}')
	set_value("type",'{:I('type')}')
	set_value("create_user_id",'{:I('create_user_id')}')
	
	//默认活动
	if("0" != "{:C('JJHH_ACTIVITY_ID')}" && "{:I('activity_id')}"==0){
		set_value('activity_id', "{:C('JJHH_ACTIVITY_ID')}");
		change_merchant(activity_id, "{:U('Shop/getActivityMerchant')}");
	}
});

//补打凭证
function pay_print(payment_id){
	if(payment_id == 0){
		return false;
	}
	window.open("__APP__/Order/printSupply/payment_id/" + payment_id ,"_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes");
}
//导航高亮
highlight_subnav("{:U('Order/payment')}");
</script>
</block>